<!doctype html public "-//W3C//DTD HTML 4.0 Frameset//EN""http://www.w3.org/TR/REC-html40/frameset.dtd">
<html>
<head>
<title>
 Overview
</title>
<link rel ="stylesheet" type="text/css" href="stylesheet.css" title="Style">
<script>
function asd() {
	
		parent.document.title="Canvas.js Overview";
	
}
</script>
</head>
<body bgcolor="white" onload="asd();">

<!-- ========== START OF NAVBAR ========== -->
<a name="navbar_top"><!-- --></a>
<table border="0" width="100%" cellpadding="1" cellspacing="0">
<tr>
<td colspan=2 bgcolor="#EEEEFF" class="NavBarCell1">
<a name="navbar_top_firstrow"><!-- --></a>
<table border="0" cellpadding="0" cellspacing="3">
  <tr align="center" valign="top">
  
  
  <td bgcolor="#EEEEFF" class="NavBarCell1">    <a href="overview-summary.html"><font class="NavBarFont1"><b>Overview</b></font></a>&nbsp;</td>
  <td bgcolor="#FFFFFF" class="NavBarCell1Rev">	&nbsp;<font class="NavBarFont1Rev"><b>File</b></font>&nbsp;</td>
  

  <td bgcolor="#FFFFFF" class="NavBarCell1"> 	<font class="NavBarFont1">Class</font>&nbsp;</td>
  <td bgcolor="#EEEEFF" class="NavBarCell1">    <a href="overview-tree.html"><font class="NavBarFont1"><b>Tree</b></font></a>&nbsp;</td>
  <td bgcolor="#EEEEFF" class="NavBarCell1">    <a href="index-all.html"--><font class="NavBarFont1"><b>Index</b></font></a>&nbsp;</td>
  <td bgcolor="#EEEEFF" class="NavBarCell1">    <a href="help-doc.html"><font class="NavBarFont1"><b>Help</b></font></a>&nbsp;</td>
  </tr>
</table>
</td>
<td bgcolor="#EEEEFF" align="right" valign="top">
<em>
<b></b></em>
</td>
</tr>

<tr>
<td bgcolor="white" class="NavBarCell2"><font size="-2">
&nbsp;PREV&nbsp;
&nbsp;NEXT</font></td>
<td bgcolor="white" class="NavBarCell2"><font size="-2">
  <a href="index.html" target="_top"><b>FRAMES</b></a>  &nbsp;
&nbsp;<a href="overview-summary.html" target="_top"><b>NO FRAMES</b></a>
&nbsp;&nbsp;
<script>
  <!--
  if(window==top) {
    document.writeln('<A HREF="allclasses-noframe.html" TARGET=""><B>All Classes</B></A>');
  }
  //-->
</script>
<noscript>
<a href="allclasses-noframe.html" target=""><b>All Classes</b></a>
</noscript>
</font></td>
</tr>
</table>
<!-- =========== END OF NAVBAR =========== -->

<hr>
<center>
	
	   <h2>Canvas.js</h2>
	
</center>

	


<h4>Summary</h4>
<p>
	
		No overview generated for 'Canvas.js'<BR/><BR/>
	
</p>

<hr>


    <table border="1" cellpadding="3" cellspacing="0" width="100%">
    <tr bgcolor="#CCCCFF" class="TableHeadingColor">
    <td colspan=2><font size="+2">
    
        <b>Class Summary</b>
    
    </font></td>
    </tr>
    
    <tr bgcolor="white" class="TableRowColor">
    <td width="15%"><b><a href="draw2d/Canvas.html">draw2d.Canvas</a></b></td>
    <td>&nbsp;</td>
    </tr>
    
    </table>
    <hr/> 


<!-- ========== METHOD SUMMARY =========== -->

<!-- ========== END METHOD SUMMARY =========== -->


        <pre class="sourceview"><span class="comment">/* This notice must be untouched at all times.

FreeGroup Draw2D 0.9.26
The latest version is available at
http://www.freegroup.de

Copyright (c) 2006 Andreas Herz. All rights reserved.
Created 5. 11. 2006 by Andreas Herz (Web: http://www.freegroup.de )

LICENSE: LGPL

This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License (LGPL) as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.

This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA,
or see http://www.gnu.org/copyleft/lesser.html
*/</span>


<span class="comment">/**
 * 
 * <span class="attrib">@version</span> 0.9.26
 * <span class="attrib">@author</span> Andreas Herz
 * <span class="attrib">@constructor</span>
 */</span>
draw2d.Canvas=<span class="reserved">function</span>(<span class="comment">/*:String*/</span> canvasId)
{
  try
  {
    <span class="reserved">if</span>(canvasId)
    <span class="reserved">this</span>.construct(canvasId);
    <span class="comment">/** <span class="attrib">@private</span> */</span>
    <span class="reserved">this</span>.enableSmoothFigureHandling = false;
    <span class="comment">/** <span class="attrib">@private</span> */</span>
    <span class="reserved">this</span>.canvasLines  = new draw2d.ArrayList();
  }
  catch(e)
  {
     pushErrorStack(e, <span class="literal">"draw2d.Canvas=function(/*:String*/id)"</span>);
  }
};

<span class="comment">// Some common configuration parameters</span>
draw2d.Canvas.IMAGE_BASE_URL =<span class="literal">""</span>;


<span class="comment">/** <span class="attrib">@private</span> **/</span>
draw2d.Canvas.<span class="reserved">prototype</span>.type=<span class="literal">"draw2d.Canvas"</span>;

<span class="comment">/**
 * <span class="attrib">@private</span>
 **/</span>
draw2d.Canvas.<span class="reserved">prototype</span>.construct=<span class="reserved">function</span>(<span class="comment">/*:String*/</span> canvasId)
{
  <span class="reserved">this</span>.canvasId = canvasId;
  <span class="reserved">this</span>.html = document.getElementById(<span class="reserved">this</span>.canvasId);
  <span class="reserved">this</span>.scrollArea = document.body.parentNode;
};


<span class="comment">/**
 * Setting the view for the canvas. A view is the part which has the scrolbar for the 
 * Canvas. See in the examples &lt;b&gt;viewport&lt;/b&gt; or more information and usage.
 *
 **/</span>
draw2d.Canvas.<span class="reserved">prototype</span>.setViewPort= <span class="reserved">function</span>( <span class="comment">/*:String*/</span> divId)
{
  <span class="reserved">this</span>.scrollArea = document.getElementById(divId);
};


<span class="comment">/**
 * <span class="attrib">@param</span> {draw2d.Figure} figure The figure object to add to the canvas
 * <span class="attrib">@param</span> {int} xPos The x coordinate for the figure
 * <span class="attrib">@param</span> {int} yPos The y coordinate for the figure
 **/</span>
draw2d.Canvas.<span class="reserved">prototype</span>.addFigure= <span class="reserved">function</span>( <span class="comment">/*:draw2d.Figure*/</span>figure,<span class="comment">/*:int*/</span> xPos,<span class="comment">/*:int*/</span> yPos, <span class="comment">/*:boolean*/</span> avoidPaint)
{
   try
   {
    <span class="reserved">if</span>(<span class="reserved">this</span>.enableSmoothFigureHandling===true)
    {
        <span class="reserved">if</span>(figure.timer&lt;=0)
          figure.setAlpha(0.001);
        var oFigure = figure;
        var slowShow = <span class="reserved">function</span>()
        {
          <span class="reserved">if</span>(oFigure.alpha&lt;1.0)
              oFigure.setAlpha(Math.min(1.0,oFigure.alpha+0.05));
          <span class="reserved">else</span>
          {
              window.clearInterval(oFigure.timer);
              oFigure.timer = -1;
          }
        };
        <span class="reserved">if</span>(oFigure.timer&gt;0)
          window.clearInterval(oFigure.timer);
        oFigure.timer = window.setInterval(slowShow,30);
    }

    figure.setCanvas(<span class="reserved">this</span>);
    <span class="reserved">if</span>(xPos &amp;&amp; yPos)
      figure.setPosition(xPos,yPos);

    <span class="reserved">if</span>(figure instanceof draw2d.Line)
    {
        <span class="reserved">this</span>.canvasLines.add(figure);
        <span class="reserved">this</span>.html.appendChild(figure.getHTMLElement());
    }
    <span class="reserved">else</span>
    {
        <span class="comment">// lines are always on top. Determine the first line and add the HTML of the none Line element before.</span>
        var obj = <span class="reserved">this</span>.canvasLines.getFirstElement();
        <span class="reserved">if</span>(obj===null)
          <span class="reserved">this</span>.html.appendChild(figure.getHTMLElement());
        <span class="reserved">else</span>
          <span class="reserved">this</span>.html.insertBefore(figure.getHTMLElement(),obj.getHTMLElement());
    }
    <span class="reserved">if</span>(!avoidPaint)
        figure.paint();
  }
  catch(e)
  {
      pushErrorStack(e,<span class="literal">"draw2d.Canvas.prototype.addFigure= function( /*:draw2d.Figure*/figure,/*:int*/ xPos,/*:int*/ yPos, /*:boolean*/ avoidPaint)"</span>);
  }
};

<span class="comment">/**
 * <span class="attrib">@param</span> {draw2d.Figure} figure The figure which should be remove from the canvas
 **/</span>
draw2d.Canvas.<span class="reserved">prototype</span>.removeFigure=<span class="reserved">function</span>(<span class="comment">/*:draw2d.Figure*/</span> figure)
{
   <span class="reserved">if</span>(<span class="reserved">this</span>.enableSmoothFigureHandling===true)
   {
      var oThis = <span class="reserved">this</span>;
      var oFigure = figure;
      var slowShow = <span class="reserved">function</span>()
      {
         <span class="reserved">if</span>(oFigure.alpha&gt;0.0)
            oFigure.setAlpha(Math.max(0.0,oFigure.alpha-0.05));
         <span class="reserved">else</span>
         {
            window.clearInterval(oFigure.timer);
            oFigure.timer =-1;
            oThis.html.removeChild(oFigure.html);
            oFigure.setCanvas(null);
         }
      };
      <span class="reserved">if</span>(oFigure.timer&gt;0)
         window.clearInterval(oFigure.timer);
      oFigure.timer = window.setInterval(slowShow,20);
   }
   <span class="reserved">else</span>
   {
      <span class="reserved">this</span>.html.removeChild(figure.html);
      figure.setCanvas(null);
   }
   <span class="reserved">if</span>(figure instanceof draw2d.Line)
      <span class="reserved">this</span>.canvasLines.remove(figure);
};

<span class="comment">/**
 * Returns the flag if the Canvas has enabled the smooth figure handling during add, remove, selection,
 * drag&amp;drop.
 *
 * <span class="attrib">@type</span> boolean
 **/</span>
draw2d.Canvas.<span class="reserved">prototype</span>.getEnableSmoothFigureHandling=<span class="reserved">function</span>()
{
    <span class="reserved">return</span> <span class="reserved">this</span>.enableSmoothFigureHandling;
};

<span class="comment">/**
 * Set the flag for the smooth figure handling during add, remove, selection,
 * drag&amp;drop.
 *
 * <span class="attrib">@param</span> {boolean} flag The smooth figure handling flag.
 **/</span>
draw2d.Canvas.<span class="reserved">prototype</span>.setEnableSmoothFigureHandling=<span class="reserved">function</span>(<span class="comment">/*:boolean*/</span> flag)
{
    <span class="reserved">this</span>.enableSmoothFigureHandling=flag;
};


<span class="comment">/**
 * Returns the width of the canvas or the width of the scrollArea if set.
 * <span class="attrib">@type</span> int
 **/</span>
draw2d.Canvas.<span class="reserved">prototype</span>.getWidth=<span class="reserved">function</span>()
{
<span class="comment">//  if(this.scrollArea!==null)</span>
<span class="comment">//    return parseInt(this.scrollArea.style.width);</span>
<span class="comment">//  else</span>
    <span class="reserved">return</span> parseInt(<span class="reserved">this</span>.html.style.width);
};

<span class="comment">/**
 * Set the new width of the canvas or the scrollArea
 *
 * <span class="attrib">@since</span> 0.9.18
 * <span class="attrib">@param</span> {int} width the new width of the canvas.
 **/</span>
draw2d.Canvas.<span class="reserved">prototype</span>.setWidth=<span class="reserved">function</span>(<span class="comment">/*:int*/</span> width)
{
  <span class="reserved">if</span>(<span class="reserved">this</span>.scrollArea!==null)
    <span class="reserved">this</span>.scrollArea.style.width=width+<span class="literal">"px"</span>;
  <span class="reserved">else</span>
    <span class="reserved">this</span>.html.style.width=width+<span class="literal">"px"</span>;
};

<span class="comment">/**
 * <span class="attrib">@type</span> int
 **/</span>
draw2d.Canvas.<span class="reserved">prototype</span>.getHeight=<span class="reserved">function</span>()
{
<span class="comment">//  if(this.scrollArea!==null)</span>
<span class="comment">//    return parseInt(this.scrollArea.style.height);</span>
<span class="comment">//  else</span>
    <span class="reserved">return</span> parseInt(<span class="reserved">this</span>.html.style.height);
};

<span class="comment">/**
 * Set the new height of the canvas or the scrollArea
 *
 * <span class="attrib">@param</span> {int} height the new height of the canvas.
 * <span class="attrib">@since</span> 0.9.18
 **/</span>
draw2d.Canvas.<span class="reserved">prototype</span>.setHeight=<span class="reserved">function</span>(<span class="comment">/*:int*/</span> height)
{
  <span class="reserved">if</span>(<span class="reserved">this</span>.scrollArea!==null)
    <span class="reserved">this</span>.scrollArea.style.height=height+<span class="literal">"px"</span>;
  <span class="reserved">else</span>
    <span class="reserved">this</span>.html.style.height=height+<span class="literal">"px"</span>;
};

<span class="comment">/**
 * Set the background image of the Canvas. The URL can be absolute, like http://www.any.com/myimg.png or relative.
 * 
 * Set the background image of the canvas
 * <span class="attrib">@param</span> {String} imageUrl The url of the background image.
 * 
 **/</span>
draw2d.Canvas.<span class="reserved">prototype</span>.setBackgroundImage=<span class="reserved">function</span>(<span class="comment">/*:String */</span> imageUrl, <span class="comment">/*:boolean*/</span> repeat)
{
   <span class="reserved">if</span>(imageUrl!==null)
   {
      <span class="reserved">if</span>(repeat)
         <span class="reserved">this</span>.html.style.background=<span class="literal">"transparent url("</span>+imageUrl+<span class="literal">") "</span>;
      <span class="reserved">else</span>
         <span class="reserved">this</span>.html.style.background=<span class="literal">"transparent url("</span>+imageUrl+<span class="literal">") no-repeat"</span>;
   }
   <span class="reserved">else</span>
   {
      <span class="reserved">this</span>.html.style.background=<span class="literal">"transparent"</span>;
   }
};

<span class="comment">/**
 * <span class="attrib">@returns</span> The Y coordinate in relation the Canvas.
 * <span class="attrib">@type</span> int
 **/</span>
draw2d.Canvas.<span class="reserved">prototype</span>.getY=<span class="reserved">function</span>()
{
  <span class="reserved">return</span> <span class="reserved">this</span>.y;
};

<span class="comment">/**
 * <span class="attrib">@returns</span> The X coordinate in relation to the canvas
 * <span class="attrib">@type</span> int
 **/</span>
draw2d.Canvas.<span class="reserved">prototype</span>.getX=<span class="reserved">function</span>()
{
  <span class="reserved">return</span> <span class="reserved">this</span>.x;
};


<span class="comment">/**
 * <span class="attrib">@returns</span> The Y coordinate in relation the Canvas.
 * <span class="attrib">@type</span> int
 **/</span>
draw2d.Canvas.<span class="reserved">prototype</span>.getAbsoluteY=<span class="reserved">function</span>()
{
  var el = <span class="reserved">this</span>.html;
  var ot=el.offsetTop;
  <span class="reserved">while</span>((el=el.offsetParent) !== null)
  {
     ot += el.offsetTop;
  }
  <span class="reserved">return</span> ot;
};

<span class="comment">/**
 * <span class="attrib">@returns</span> The X coordinate in relation to the canvas
 * <span class="attrib">@type</span> int
 **/</span>
draw2d.Canvas.<span class="reserved">prototype</span>.getAbsoluteX=<span class="reserved">function</span>()
{
    var el = <span class="reserved">this</span>.html;
    var ol=el.offsetLeft;
    <span class="reserved">while</span>((el=el.offsetParent) !== null)
    {
        ol += el.offsetLeft;
    }
    <span class="reserved">return</span> ol;
};



<span class="comment">/**
 * <span class="attrib">@returns</span> The Y coordinate in relation the Canvas.
 * <span class="attrib">@type</span> int
 **/</span>
draw2d.Canvas.<span class="reserved">prototype</span>.getScrollLeft=<span class="reserved">function</span>()
{
  <span class="reserved">return</span> <span class="reserved">this</span>.scrollArea.scrollLeft;
};

<span class="comment">/**
 * <span class="attrib">@returns</span> The X coordinate in relation to the canvas
 * <span class="attrib">@type</span> int
 **/</span>
draw2d.Canvas.<span class="reserved">prototype</span>.getScrollTop=<span class="reserved">function</span>()
{
  <span class="reserved">return</span> <span class="reserved">this</span>.scrollArea.scrollTop;
};


</pre>
	<hr>



<!-- ========== START OF NAVBAR ========== -->
<a name="navbar_top"><!-- --></a>
<table border="0" width="100%" cellpadding="1" cellspacing="0">
<tr>
<td colspan=2 bgcolor="#EEEEFF" class="NavBarCell1">
<a name="navbar_top_firstrow"><!-- --></a>
<table border="0" cellpadding="0" cellspacing="3">
  <tr align="center" valign="top">
  
  
  <td bgcolor="#EEEEFF" class="NavBarCell1">    <a href="overview-summary.html"><font class="NavBarFont1"><b>Overview</b></font></a>&nbsp;</td>
  <td bgcolor="#FFFFFF" class="NavBarCell1Rev">	&nbsp;<font class="NavBarFont1Rev"><b>File</b></font>&nbsp;</td>
  

  <td bgcolor="#FFFFFF" class="NavBarCell1"> <font class="NavBarFont1">Class</font>&nbsp;</td>
  <td bgcolor="#EEEEFF" class="NavBarCell1">    <a href="overview-tree.html"><font class="NavBarFont1"><b>Tree</b></font></a>&nbsp;</td>
  <td bgcolor="#EEEEFF" class="NavBarCell1">    <a href="index-all.html"--><font class="NavBarFont1"><b>Index</b></font></a>&nbsp;</td>
  <td bgcolor="#EEEEFF" class="NavBarCell1">    <a href="help-doc.html"><font class="NavBarFont1"><b>Help</b></font></a>&nbsp;</td>
  </tr>
</table>
</td>
<td bgcolor="#EEEEFF" align="right" valign="top"><em>
<b></b></em>
</td>
</tr>

<tr>
<td bgcolor="white" class="NavBarCell2"><font size="-2">
&nbsp;PREV&nbsp;
&nbsp;NEXT</font></td>
<td bgcolor="white" class="NavBarCell2"><font size="-2">
  <a href="index.html" target="_top"><b>FRAMES</b></a>  &nbsp;
&nbsp;<a href="overview-summary.html" target="_top"><b>NO FRAMES</b></a>
&nbsp;&nbsp;
<script>
  <!--
  if(window==top) {
    document.writeln('<A HREF="allclasses-noframe.html" TARGET=""><B>All Classes</B></A>');
  }
  //-->
</script>
<noscript>
<a href="allclasses-noframe.html" target=""><b>All Classes</b></a>
</noscript>
</font></td>
</tr>
</table>
<!-- =========== END OF NAVBAR =========== -->

<hr>
<font size="-1">

</font>
<div class="jsdoc_ctime">Documentation generated by <a href="http://jsdoc.sourceforge.net/" target="_parent">JSDoc</a> on Mon Nov 14 13:45:39 2011</div>
</body>
</html>
